using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.AI.Node
{
    [Category("✫ Utility")]
    public class WaitRandom : ActionTask
    {
        public BBParameter<float> min = 0f;
        public BBParameter<float> max = 1f;
        
        public CompactStatus finishStatus = CompactStatus.Success;

        private float waitTime = 0f;
        protected override string info {
            get { return string.Format("Wait [{0}, {1}] sec.", min.value, max.value); }
        }

        protected override void OnExecute()
        {
            waitTime = Random.Range(min.value, max.value);
        }

        protected override void OnUpdate() {
            if ( elapsedTime >= waitTime ) {
                EndAction(finishStatus == CompactStatus.Success ? true : false);
            }
        }
    }
}